/**
 * TO BE DETERMINED
 */
package org.eichar.server.i18n;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * 
 * @author Jesse
 */
public class Messages {
    private static final String BUNDLE_NAME = "org.eichar.server.service.messages"; //$NON-NLS-1$

    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
            .getBundle(BUNDLE_NAME);

    private Messages() {
    }

    public static String getString(String key) {
        try {
            return RESOURCE_BUNDLE.getString(key);
        } catch (MissingResourceException e) {
            return '!' + key + '!';
        }
    }

    public static String getString(String key, String... parameters) {
        try {
            String message = RESOURCE_BUNDLE.getString(key);
            for (int i = 0; i < parameters.length; i++) {
                String paramKey = "{" + i + "}"; //$NON-NLS-1$ //$NON-NLS-2$
                message = message.replace(paramKey, parameters[i]);
            }
            return message;
        } catch (MissingResourceException e) {
            return '!' + key + '!';
        }
    }
}
